

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Inference &mdash; PackNet-SfM 1.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Trainers" href="../trainers/trainers.html" />
    <link rel="prev" title="Evaluation" href="scripts.eval.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html">
          

          
            
            <img src="../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../configs/configs.html">Configs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="scripts.html">Scripts</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="scripts.train.html">Training</a></li>
<li class="toctree-l2"><a class="reference internal" href="scripts.eval.html">Evaluation</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Inference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../trainers/trainers.html">Trainers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../datasets/datasets.html">Datasets</a></li>
<li class="toctree-l1"><a class="reference internal" href="../models/models.html">Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="../networks/networks.html">Networks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../losses/losses.html">Losses</a></li>
<li class="toctree-l1"><a class="reference internal" href="../loggers/loggers.html">Loggers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../geometry/geometry.html">Geometry</a></li>
<li class="toctree-l1"><a class="reference internal" href="../utils/utils.html">Utils</a></li>
</ul>
<p class="caption"><span class="caption-text">Contact</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://tri.global">Toyota Research Institute</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/TRI-ML/packnet-sfm">PackNet-SfM GitHub</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/TRI-ML/DDAD">DDAD GitHub</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">PackNet-SfM</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="scripts.html">Scripts</a> &raquo;</li>
        
      <li>Inference</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/scripts/scripts.infer.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-scripts.infer">
<span id="inference"></span><h1>Inference</h1>
<dl class="py function">
<dt id="scripts.infer.imwrite">
<code class="sig-prename descclassname">scripts.infer.</code><code class="sig-name descname">imwrite</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">img</em><span class="optional">[</span>, <em class="sig-param">params</em><span class="optional">]</span><span class="sig-paren">)</span> &#x2192; retval</dt>
<dd><p>.   &#64;brief Saves an image to a specified file.
.
.   The function imwrite saves the image to the specified file. The image format is chosen based on the
.   filename extension (see cv::imread for the list of extensions). In general, only 8-bit
.   single-channel or 3-channel (with ‘BGR’ channel order) images
.   can be saved using this function, with these exceptions:
.
.   - 16-bit unsigned (CV_16U) images can be saved in the case of PNG, JPEG 2000, and TIFF formats
.   - 32-bit float (CV_32F) images can be saved in PFM, TIFF, OpenEXR, and Radiance HDR formats;
.   3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding
.   (4 bytes per pixel)
.   - PNG images with an alpha channel can be saved using this function. To do this, create
.   8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels
.   should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).
.
.   If the format, depth or channel order is different, use
.   Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O
.   functions to save the image to XML or YAML format.
.
.   The sample below shows how to create a BGRA image and save it to a PNG file. It also demonstrates how to set custom
.   compression parameters:
.   &#64;include snippets/imgcodecs_imwrite.cpp
.   &#64;param filename Name of the file.
.   &#64;param img Image to be saved.
.   &#64;param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, … .) see cv::ImwriteFlags</p>
</dd></dl>

<dl class="py function">
<dt id="scripts.infer.infer_and_save_depth">
<code class="sig-prename descclassname">scripts.infer.</code><code class="sig-name descname">infer_and_save_depth</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scripts/infer.html#infer_and_save_depth"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Process a single input file to produce and save visualization</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>input_file</strong> (<em>str</em>) – Image file</p></li>
<li><p><strong>output_file</strong> (<em>str</em>) – Output file, or folder where the output will be saved</p></li>
<li><p><strong>model_wrapper</strong> (<em>nn.Module</em>) – Model wrapper used for inference</p></li>
<li><p><strong>image_shape</strong> (<em>Image shape</em>) – Input image shape</p></li>
<li><p><strong>half</strong> (<em>bool</em>) – use half precision (fp16)</p></li>
<li><p><strong>save_npz</strong> (<em>bool</em>) – save .npz output depth maps if True, else save as png</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="scripts.infer.is_image">
<code class="sig-prename descclassname">scripts.infer.</code><code class="sig-name descname">is_image</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">file</span></em>, <em class="sig-param"><span class="n">ext</span><span class="o">=</span><span class="default_value">'.png', '.jpg'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scripts/infer.html#is_image"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Check if a file is an image with certain extensions</p>
</dd></dl>

<dl class="py function">
<dt id="scripts.infer.main">
<code class="sig-prename descclassname">scripts.infer.</code><code class="sig-name descname">main</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">args</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scripts/infer.html#main"><span class="viewcode-link">[source]</span></a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="scripts.infer.parse_args">
<code class="sig-prename descclassname">scripts.infer.</code><code class="sig-name descname">parse_args</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scripts/infer.html#parse_args"><span class="viewcode-link">[source]</span></a></dt>
<dd></dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../trainers/trainers.html" class="btn btn-neutral float-right" title="Trainers" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="scripts.eval.html" class="btn btn-neutral float-left" title="Evaluation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2020, Toyota Research Institute (TRI)

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(false);
      });
  </script>

  
  
    
   

</body>
</html>